package java02;


import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		ArrayList<Integer> List = new ArrayList<Integer>();
		while(sc.hasNext()){
			String str=sc.nextLine();
			if (str.equals("fib")) {
                               String str2 = sc.nextLine();
				int n = Integer.valueOf(str2);
				if (n <= 0) break;
				int a[] = new int[n];
				for (int i = 1; i <= n; i++) {
					a[i - 1] = fib(i);
				}
				for (int i = 0; i < a.length - 1; i++) {
					System.out.print(a[i] + " ");
				}
				System.out.println(a[a.length - 1]);
			}else if (str.equals("sort")){
				List.removeAll(List);
				String line=sc.nextLine();
				String[] strdigits=line.split(" ");
				for (int j = 0; j < strdigits.length; j++) {
					List.add(Integer.valueOf(strdigits[j]));
				}
				Collections.sort(List);
				System.out.println(List);
			}else if (str.equals("search")) {
				String str1 = sc.nextLine();
				int num = Integer.valueOf(str1);
				System.out.println(List.indexOf(num));
			}else if (str.equals("getBirthDate")) {
				String str1 = sc.nextLine();
				int x = Integer.valueOf(str1);
				for (int i = 0; i < x; i++) {
					String idnum=sc.nextLine();
					getBirthDate(idnum);
				}
			}else {
				System.out.println("exit");
				break;
			}
		}
		sc.close();
	}
	private static void getBirthDate(String idnum) {
		String year=idnum.substring(6, 10);
		String month=idnum.substring(10,12);
		String day=idnum.substring(12,14);
		System.out.println(year+"-"+month+"-"+day);
	}
	private static int fib(int n) {
		if (1 == n)	return 1;
		if (2 == n)	return 1;
		else return fib(n - 1) + fib(n - 2);
	}
}
